package com.ruoyi.gateway.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import com.ruoyi.gateway.handler.SentinelFallbackHandler;

/**
 * Spring Cloud Gateway 限流配置类，使用了 Sentinel 进行网关流控和降级处理。
 * @说明: <a href="https://doc.ruoyi.vip/ruoyi-cloud/cloud/sentinel.html#%E5%9F%BA%E6%9C%AC%E4%BB%8B%E7%BB%8D">Sentinel</a>
 * @author ruoyi
 */
@Configuration
public class GatewayConfig
{
    @Bean
    @Order(Ordered.HIGHEST_PRECEDENCE) //指定 Bean 的加载顺序。
    public SentinelFallbackHandler sentinelGatewayExceptionHandler() {
        return new SentinelFallbackHandler();
    }
}